<?php
$__tpl['header'] = THR_PTH.'_manager/index/_header.tpl';
$__tpl['footer'] = THR_PTH.'_manager/index/_footer.tpl';

$_f_stat = cache_read('stat.php');
if(empty($_f_stat) || (TIME - $_f_stat['time'] > 300)){	// 5分钟后再更新
	$_f_stat = array('time' => TIME);

	$oOrder = new Order();
	$_f_stat['order_stats'] = $oOrder->state_stat();

	$lacklist = $oOrder->get_lack_list('*', null, array('id' => 'DESC'), 1, 20, 0);
	if(!empty($lacklist['list']) && is_array($lacklist['list'])){
		foreach($lacklist['list'] as $key => $row){
			$row['goodsinfo']['fweight'] = format_weight_out($row['goodsinfo']['weight'], $row['goodsinfo']['weightunit']);
			if(!empty($row['goodsinfo']['filename'])){
				$row['url'] = PUB_DIR.'goods/'.$row['goodsinfo']['filename'].'.html';
			}else{
				$row['url'] = PUB_DIR.'goods/'.time_to_path($row['goodsinfo']['addtime']).'/'.$row['goodsinfo']['id'].'.html';
			}
			$lacklist['list'][$key] = $row;
		}
		$_f_stat['lacklist'] = $lacklist['list'];
	}

	$oGoods = new Goods();

	$salelist = $oGoods->get_list('*', array('kept' => ' AND `t`.`sales`>0'), array('orderby_sales' => 'DESC'), 1, 100, $offset = 0);
	if(!empty($salelist['list']) && is_array($salelist['list'])){

		foreach($salelist['list'] as $key => $row){
			if(empty($row['filename'])){
				$row['url'] = PUB_DIR.'goods/'.time_to_path($row['addtime']).'/'.$row['id'].'.html';
			}else{
				$row['url'] = PUB_DIR.'goods/'.$row['filename'].'.html';
			}
			$salelist['list'][$key] = $row;
		}
		$_f_stat['salelist'] = $salelist['list'];
	}

	cache_write('stat.php', $_f_stat);
}

$vars['order_stats'] = $_f_stat['order_stats'];
if(isset($_f_stat['lacklist'])){
	$vars['lacklist'] = $_f_stat['lacklist'];
}
if(isset($_f_stat['salelist'])){
	$vars['salelist'] = $_f_stat['salelist'];
}

License::system_update_notification();
$_f_notice = License::get_notice();
if(!empty($_f_notice['list'])){
	foreach($_f_notice['list'] as $key => $row){
		$row['updatetime'] = ftime($row['updatetime']);
		$_f_notice['list'][$key] = $row;
	}
	$vars['noticelist'] = $_f_notice['list'];
}
?>
